package com.pattern.responsibility.advance;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author qingshan
 * @since 2020-09-15 17:06
 */
public class FilterChain implements Filter {

    List<Filter> filters = new ArrayList<Filter>();

    public FilterChain addFilter(Filter f){
        filters.add(f);
        return this;
    }

    public boolean doFilter(Msg msg){
        for (Filter f : filters){
            f.doFilter(msg);
        }
        return true;
    }
}
